package cz.proks.bank.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class Payment implements Serializable {
	public enum State {
		NEW, DEDUCTED_FROM_SOURCE_ACCOUNT, CREDITED_TO_TARGET_ACCOUNT, WAITING_FOR_OTHER_BANK, OK, ERROR
	}
	
	@Id @GeneratedValue
	private long id;	
	
	@Column
	private long clearingPaymentId;
	
	@Column(nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date date;
	
	@Column(nullable = false)
	private int sourceAccountId;
	
	@Column(nullable = false)
	private int targetAccountId;
	
	@Column(nullable = false)
	private String sourceBankCode;
	
	@Column(nullable = false)
	private String targetBankCode;
	
	@Column(nullable = false)
	private long amount;
	
	@Column(nullable = false)
	private String currency;
	
	@Enumerated @Column(nullable = false)
	private State paymentState;	
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}			
	public long getClearingPaymentId() {
		return clearingPaymentId;
	}
	public void setClearingPaymentId(long clearingPaymentId) {
		this.clearingPaymentId = clearingPaymentId;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}	
	public int getSourceAccountId() {
		return sourceAccountId;
	}
	public void setSourceAccountId(int sourceAccountId) {
		this.sourceAccountId = sourceAccountId;
	}	
	public int getTargetAccountId() {
		return targetAccountId;
	}
	public void setTargetAccountId(int targetAccountId) {
		this.targetAccountId = targetAccountId;
	}		
	public String getSourceBankCode() {
		return sourceBankCode;
	}
	public void setSourceBankCode(String sourceBankCode) {
		this.sourceBankCode = sourceBankCode;
	}
	public String getTargetBankCode() {
		return targetBankCode;
	}
	public void setTargetBankCode(String targetBankCode) {
		this.targetBankCode = targetBankCode;
	}
	public long getAmount() {
		return amount;
	}
	public void setAmount(long amount) {
		this.amount = amount;
	}
	public String getCurrency() {
		return currency;
	}
	public void setCurrency(String currency) {
		this.currency = currency;
	}
	public State getPaymentState() {
		return paymentState;
	}
	public void setPaymentState(State paymentState) {
		this.paymentState = paymentState;
	}	
	@Override
	public String toString() {
		return "Payment [id='" + id + "', clearingCenterId='"
				+ clearingPaymentId + "', date='" + date
				+ "', sourceAccountId='" + sourceAccountId
				+ "', targetAccountId='" + targetAccountId
				+ "', sourceBankCode='" + sourceBankCode
				+ "', targetBankCode='" + targetBankCode + "', amount='"
				+ amount + "', currency='" + currency + "', paymentState='"
				+ paymentState + "]";
	}		
}
